/**
 * @param {string[]} recipes
 * @param {string[][]} ingredients
 * @param {string[]} supplies
 * @return {string[]}
 */
 var findAllRecipes = function(recipes, ingredients, supplies) {
  const n = recipes.length
  let g = {}
  for(let i = 0; i<n; i++){
    let x = recipes[i], y = ingredients[i]
    g[x] = y
  }
  const s = new Set(supplies)
  let ans = []
  const dfs = (x) => {
    if(!g[x] || s.has(x)){
      return s.has(x)
    }
    let flag = true
    for(let next of g[x]){
      if(!dfs(next)) flag = false
    }
    return flag
  }
  for(let i = 0; i<n; i++){
    let flag = true
    for(let x of ingredients[i]){
      if(!dfs(x)) flag = false
    }
    if(flag){
      for(let x of ingredients[i]) s.add(x)
      s.add(recipes[i])
      ans.push(recipes[i])
    }
  }
  return ans
};